package com.ruoyi.quartz.task;

import cn.hutool.core.collection.CollUtil;
import com.ruoyi.account.service.IAccountApplyRecordService;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.db.domain.AccountApplyRecord;
import com.ruoyi.notice.enums.MessageTypeEnum;
import com.ruoyi.notice.service.IMessageNoticeService;
import com.ruoyi.notice.service.impl.MessageNoticeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("applyRecordNoticeTask")
public class ApplyRecordNoticeTask
{

    @Autowired
    IAccountApplyRecordService accountApplyRecordService;
    @Autowired
    IMessageNoticeService messageNoticeService;

    public void noticeRecord()
    {

        AccountApplyRecord accountApplyRecord = new AccountApplyRecord();
        accountApplyRecord.setStatus(1);
        accountApplyRecord.setDelFlag(0L);

        List<AccountApplyRecord> accountApplyRecords = accountApplyRecordService.selectAccountApplyRecordList(accountApplyRecord);

        List<String> idList = new ArrayList<>();
        for (AccountApplyRecord applyRecord : accountApplyRecords) {
            idList.add(String.valueOf(applyRecord.getId()));
        }

        if (CollUtil.isNotEmpty(idList)){
            messageNoticeService.noticeMsgHandle(MessageTypeEnum.BILL_ENTER_WARNING, idList, null);
        }

    }
}
